<template>
<h2>显示用户</h2>



会员等级：
<select v-model="Rid">

<option :value="-1">--请选择--</option>
<option  v-for="item in Xialala2" :value="item.Rank_Id">{{ item.Rank_Name }}</option>
</select>


性别：<input type="radio"  value="true" v-model="Sex">男
<input type="radio"  value="false" v-model="Sex">女


姓名：<input type="text"  v-model="Name">


<button value="搜索" @click="ShowMe">搜索</button>


<table class="table table-bordered">
    <thead>
        <tr>
                 <th>
                        姓名
                </th>       
                <th>
                        账号
                </th>

                <th>
                        手机号
                </th>

                <th>
                        性别
                </th>


                <th>
                        身份证
                </th>

                <th>
                        生日
                </th>

                <th>
                        价钱
                </th>

                <th>
                        状态
                </th>
                
                <th>
                        积分
                </th>
                
                <th>
                        身份
                </th>
                
                <th>
                        类型
                </th>
        </tr>
        
        
    </thead>




    <tbody v-for="item in ss">



        <tr >
                 <th>
                        {{ item.Name }}
                </th>       
                <th>
                        {{ item.Member_Name }}
                </th>

                <th>
                        {{ item.Member_Phone }}
                </th>

                <th>
                        {{ item.Member_Phone }}
                </th>


                <th>
                        {{ item .Member_IdCard }}
                </th>

                <th>
                        {{ item.Member_Birthday }}
                </th>

                <th>
                        {{ item.Member_Money }}
                </th>

                <th>
                        {{ item.Member_State }}
                </th>
                
                <th>
                        {{ item.Member_Integration }}
                </th>
                
                <th>
                        {{ item.MemberType_Id }}
                </th>
                
                <th>
                        {{ item.Rank_id }}
                </th>

                <th>
                       <button @click="IsDel(item.Id)">删除</button>

                       <a href="#" @click="Xg(item.Id)">修改</a>
                </th>
        </tr>





    </tbody>


</table>




</template>


<script setup lang="ts">
import axios from 'axios';
import { onMounted } from 'vue';


import{ref} from 'vue';


onMounted(()=>{

XiaLa1();
XiaLa2();
})

const Xialala =ref([{

"MemberType_Id": -1,
"MemberType_Name": ""

}])


const XiaLa1=()=>{

axios.get('https://localhost:7035/api/Member/ShowSf').then(res=>{

   Xialala.value=res.data;

})

}

const Xialala2 =ref([{

"Rank_Id": 1,
"Rank_Name": "青铜",
"Rank_State": true,
"Rank_MaxPoint": 0,
"Rank_MinPoint": 100,
"Rank_IsDel": true,
"Rank_DeleteTime": "2024-05-05T00:00:00"

}])

const XiaLa2=()=>{

axios.get('https://localhost:7035/api/Rank/ShowRank').then(res=>{

   Xialala2.value=res.data;

})
}

const ss =ref([{

    "Id": "",
    "Member_Pwd": "",
    "Member_Name": "",
    "Name": "",
    "Member_Phone": "",
    "Member_Sex": "",
    "Member_IdCard": "",
    "Member_Birthday": "",
    "Member_Money": "",
    "Member_State": "",
    "Member_Integration": 0,
    "MemberType_Id": 0,
   
    "Rank_id": 1,
    "IsDel": true




}])


const Rid =ref(-1)
const Sex =ref('')
const Name =ref('')

const ShowMe=()=>{
    
   axios.get('https://localhost:7035/api/Member/ShowMEME',{
   params:{

    Rid:Rid.value,
    Sex:Sex.value,
    Name:Name.value
   }}).then(res=>{

         ss.value=res.data


   }).catch(error=>{

        console.log(error);

   })




}









onMounted(()=>{
    
ShowMe();
})





const IsDel=(id:number)=>{

    if(!confirm('确定删除吗'))
{
    return ;
}
    axios.delete('https://localhost:7035/api/Member/IsDelMe',{params:{
        id:id,
    }}).then(res=>{

            if(res.data>0)
            {
                alert('删除成功')
                ShowMe();
            }
            else
            {
                alert('删除失败')
            }
    })

}


import { useRouter } from 'vue-router';

const router=useRouter()
const Xg=(id:number)=>{

    router.push({
        name:'XgMember',
        params:{

            id:id
        }


    })


}




</script>